<% layout('/layout/default.html', {title: '定时任务', libs: ['dataGrid','icheck']}){ %>
<div class="main-content">
	<div class="card-header">
		<i class="fa fa-sitemap"></i> 定时任务管理
		<div class="header-tools float-right">
			<a href="#" class="btn btn-sm btn-secondary" id="btnSearch" title="查询"><i class="fa fa-filter"></i> 查询</a>
			<a href="#" class="btn btn-sm btn-secondary"  id="btnRefreshTree" title="刷新"><i class="fa fa-refresh"></i> 刷新</a>
			<% if(hasPermi('sys:job:edit')){ %>
			<a href="/sys/job/form" class="btn btn-sm btn-secondary btnTool" title="任务添加"><i class="fa fa-plus"></i>添加</a>
			<% } %>
		</div>
	</div>
	<div class="container-fluid">
		<form id="searchForm" action="${ctx}/sys/job/listAll" class="form-inline d-none">
			<div class="form-group">
				<label class="control-label">任务类名：</label>
				<div class="control-inline">
					<input name="jobClassName" class="form-control"/>
				</div>
			</div>
			<div class="form-group">
				<label class="control-label">任务所在组：</label>
				<div class="control-inline">
					<input name="jobGroupName" class="form-control"/>
				</div>
			</div>
			<div class="form-group">
				<button type="submit" class="btn btn-primary ">查询</button>
				<button type="reset" class="btn btn-secondary">重置</button>
			</div>
		</form>
		<table id="btGrid"></table>
	</div>
</div>
<% } %>
<script>
//初始化DataGrid对象
	$('#btGrid').BTGrid({
		searchForm: $("#searchForm"),
		columnModel: [
			{title:'任务类名', field:'jobClassName', width:120, align:"center", sortable:true},
            {title:'任务所在组', field:'jobGroupName', width:50, align:"center"},
			/*{header:'触发器名称', field:'triggerName', width:80, align:"center"},
			{header:'触发器所在组', field:'triggerGroupName', width:50, align:"center"},*/
            {title:'表达式', field:'cronExpression', width:80, align:"center"},
            {title:'上次执行时间', field:'prevFireTime', width:80, align:"center"},
            {title:'下次执行时间', field:'nextFireTime', width:80, align:"center"},
            {title:'状态', field:'triggerState', width:50, align:"center", formatter: function(val, row, index){
                    return js.transDictLabel(${@DictUtils.getDictListJson('sys_job_status')}, val, '未知');
             }},
			{title:'操作', width:80, align:"center", formatter: function(val, row, index){
				var actions = [];
                var operate = row.triggerState=="PAUSED"?'<a href="${ctx}/sys/job/resume?jobClassName='+row.jobClassName+'&jobGroupName='+row.jobGroupName+'" class="btn btn-sm btn-success btnList" title="恢复" data-confirm="确认要恢复任务吗？"><i class="fa fa-play"></i></a>&nbsp&nbsp':
                    	      '<a href="${ctx}/sys/job/pause?jobClassName='+row.jobClassName+'&jobGroupName='+row.jobGroupName+'" class="btn btn-sm btn-success btnList" title="暂停" data-confirm="确认要暂停任务吗？"><i class="fa fa-pause"></i></a>&nbsp&nbsp'
                <% if(hasPermi('sys:dict:edit')){ %>
					actions.push(operate);
                    actions.push('<a href="/sys/job/resetform?jobClassName='+row.jobClassName+'&jobGroupName='+row.jobGroupName+'&cronExpression='+row.cronExpression+'" class="btn btn-sm btn-primary btnList" title="重置任务"><i class="fa fa-pencil"></i></a>&nbsp&nbsp');
                    actions.push('<a href="${ctx}/sys/job/del?jobClassName='+row.jobClassName+'&jobGroupName='+row.jobGroupName+'" class="btn btn-sm btn-danger btnList" title="删除" data-confirm="确认要删除定时任务吗?"><i class="fa fa-trash-o"></i></a>');
				<% } %>
				return actions.join('');
			}}
		],
		// 加载成功后执行事件
		ajaxSuccess: function(data){
			
		}
	});
</script>